<?
    require_once("inc_security.php"); 
    
    //khoi tao object Datagird
    $menu = new menu();
    $sql = 'cat_type = 0 ';
    $listAll = $menu->getAllChild("categories_multi","cat_id ","cat_parent_id","0",$sql . "AND lang_id = " . $lang_id,"cat_id,cat_name,cat_order,cat_type,cat_parent_id,cat_has_child","cat_order ASC, cat_name ASC","cat_has_child");
    $list = new fsDataGird($id_field, $name_field, translate_text("Listing"));
    $list->add('new_picture','Ảnh','string',0,0);
    $list->add('new_title','Tên','string',1,1);
    $list->add('new_cat_id','Danh mục','int',0,1);
    $list->add('',translate_text("Chi tiết"),"linkdetails");
    $list->add('new_date','Ngày tạo','string',0,0);
    $list->add("new_hot_home","Hot Home","int", 0, 0);
    $list->add("new_hot_cat","Hot Cat","int", 0, 0);
    $list->add("new_view","Xem","int", 1, 0);
    $list->add("new_active","Active","int", 0, 0);
    $list->add('',translate_text("Edit"),"edit");
    $list->add('',translate_text("Delete"),"delete");
    $list->ajaxedit($fs_table);

    $total          = new db_count('SELECT  count(*) AS count 
                                             FROM   '.$fs_table.' 
                                             WHERE  1 ' . $list->sqlSearch());

    $db_listing     = new db_query('SELECT * 
                                           FROM '.$fs_table.'
                                           WHERE 1 ' . $list->sqlSearch() . '
                                           ORDER BY '.$id_field.' DESC,' . $list->sqlSort() . $id_field .' DESC
                                           ' . $list->limit($total->total));
    $total_row      = mysql_num_rows($db_listing->result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
<?=$list->headerScript()?>
<script language="javascript" src="../../resource/js/swfObject.js"></script>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<? /*---------Body------------*/ ?>
<div id="listing">
<?=$list->showHeader($total_row)?>
    <?
    $i = 0;
    while($row = mysql_fetch_assoc($db_listing->result)){
        $i++;
        ?>
        <?=$list->start_tr($i, $row[$id_field])?>
        <td width="60"><img height="50" width="60" style="max-width: 100%;" src="<?=$row["new_picture"];?>"/></td>
        <td width="200"><?=$row["new_title"];?></td>
        <td width="150" align="center">
          <select name="cat_type" id="cat_type"  class="form_control">
            <? foreach($listAll as $value){ ?>
            <option value="<?=$row['new_cat_id']?>" <? if($value['cat_id'] == $row['new_cat_id']) echo "selected='selected'";?>><?=$value['cat_name']?></option>
            <? } ?>
          </select>
      </td>  
        <td width="70" align="center">
            <? echo'<a title="Nội dung" class="thickbox noborder a_detail" href="showlinks.php?url='. base64_encode(getURL()) . '&lin_value=' . $row["new_id"] .'&TB_iframe=true&amp;height=900&amp;width=1000" /><b>Nội dung</b></a>';?>
        </td>
        <td align="center" width="50"><?=date(' d/m/y ',$row["new_date"])?></td>
        <?=$list->showCheckbox("new_hot_home", $row["new_hot_home"], $row[$id_field])?>
        <?=$list->showCheckbox("new_hot_cat", $row["new_hot_cat"], $row[$id_field])?>
        <td width="50" align="center"><?=$row["new_view"];?></td>
        <?=$list->showCheckbox("new_active", $row["new_active"], $row[$id_field])?>
        <?=$list->showEdit($row[$id_field]); ?>
        <?=$list->showDelete($row[$id_field]); ?>
          <?=$list->end_tr();?>
        <?
    }
    ?>
    <?=$list->showFooter($total_row); ?>
</div>
<? /*---------Body------------*/ ?>
</body>
</html>
